/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package yuhuibear.poat.test.util;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

import junit.framework.ComparisonFailure;

/**
 *
 * @author yuhuibear
 */
public class MyAssert {

    /**
     * 比较两个数组含有的元素是否完全相同， 但是不考虑顺序。
     * @param exptect
     * @param result
     * @throws java.lang.Exception
     */
	public static void arrayEqualsNoOrder(Object[] exptect, Object[] result) throws Exception {
        Set<Object> resultSet = new HashSet<Object>();
        resultSet.addAll(Arrays.asList(result));
        int i = 0;
        for (Object expt : exptect) {
            if (!resultSet.contains(expt)) {
                resultSet.removeAll(Arrays.asList(exptect));
                String rslt_msg = resultSet.toString();
                rslt_msg = rslt_msg.substring(1, rslt_msg.length()-1);
                throw new ComparisonFailure(expt +"["+i+ "] does not contains in result.", expt.toString(), rslt_msg);
            }
        }
    }
}
